package cn.bellychang.leetcode.question315;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ChangLiang
 * @date 2021/3/17
 */
public class Solution2 {

    public List<Integer> countSmaller(int[] nums) {

        List<Integer> result = new ArrayList<>();

        for (int i = 0; i < nums.length; i++) {
            result.add(getCount(nums, i));
        }

        return result;
    }

    private int getCount(int[] nums, int i) {
        int temp = nums[i];
        int count = 0;
        for (int j = i+1; j < nums.length; j++) {
            if (nums[j] < temp) {
                count++;
            }
        }
        return count;
    }
}
